<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    	String path=request.getContextPath();
    %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">

    <title>『豪情』后台管理</title>
    <link href="<%=path%>/static/manage/css/admin_login.css" rel="stylesheet" type="text/css" />


<title>Insert title here</title>
</head>
<body>



<div class="admin_login_wrap">
    <h1>后台管理</h1>
    <div class="adming_login_border">
        <div class="admin_input">
            <form id="formlogin" action="<%=request.getContextPath() %>/manage/AdminServlet?action=login" method="post">
                <ul class="admin_items">
                    <li>
                        <span for="user">用户名: </span><span id="spanusername">
                        <%
						String mag=request.getParameter("mag");
                        if("login1".equals(mag)){
                        	%>
                    		   <span id="spanid">用户名或密码错误</span>
                    		   <%
                    	} %>
                        </span>
                        <input type="text" name="username" value="" id="user" size="40" class="admin_input_style" />
                    </li>
                    <li>
                        <label for="pwd">密码:</label>
                        <input type="password" name="pwd" value="" id="pwd" size="40" class="admin_input_style" />
                    </li>
                    <li>
                        <label for="code">验证码:</label>
                        <input type="text" name="code" size="18" value="" id="code" size="40" class="admin_input_style" />
                        <img id="codeimg" src="<%=request.getContextPath() %>/CodeServlet?action=code"><br><span id="codespan"></span>
                    </li>
                    <li>
                        <input type="buttom" id="sumbtn" tabindex="3" value="提交" class="btn btn-primary" />
                    </li>
                </ul>
            </form>
        </div>
    </div>
    <p class="admin_copyright"><a tabindex="5" href="<%=path %>/manage/index.jsp" target="_blank">返回首页</a>  </p>
</div>
</body>
</html>

<script type="text/javascript" src="<%=request.getContextPath()%>/static/js/jquery-3.5.1.min.js"></script>
<script>
$(function(){
	$("#codeimg").click(function(){
		var rand=Math.random();
		$("#codeimg").attr("src","<%=request.getContextPath() %>/CodeServlet?action=code&rand="+rand);
	})
	$("#sumbtn").click(function(){
		var code=$("#code").val();
		$.ajax({
		url:"<%=path%>/CodeServlet?action=check",
		data:{code:code},
		success:function(msg){
			if("ok"==msg){
				$("#codespan").html(" ");
				$("#formlogin").submit();
			}else if("no"==msg){
				$("#codespan").html("验证码错误");
				$("#code").select();
			}
		}
	})
	})
	
})
$("#spanid").css("color","red");
$("#spanid").css("margin-left","100px");
$("#codespan").css("color","red");
</script>